/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ereconquista.dao;

import com.ereconquista.modelo.Rubro;
import java.io.Serializable;
import java.util.List;

/**
 * @author Claudio
 */
public class RubroDAO extends BaseDAO<Rubro> implements Serializable {
    
    public List<Rubro> getListaByNivel(Integer nivel, boolean  activos){
        
        try {
            
            String sQuery = "SELECT m FROM Rubro m "
                +" WHERE m.nivel = "+nivel 
                + (activos ? " AND m.activo = 'S'" : "" )
                +" ORDER BY m.orden";                       
                        
            return execQueryList(sQuery);
            
        } catch (Exception e) {
            
            System.err.print("ERROR: " + e.getMessage());
            return null;
        }
    }
        
    public int getCantidadRegistros(){
        
        return (int) getCantidadRegistros(Rubro.class);
    }

    public Rubro getRubro(int id) {
        return getObjeto(Rubro.class, id);
    }

}
